package com.cn.yz.common.page;

import java.util.List;

public class PagedData<T> {
	
	private int pageIndex = -1;
	
	private int pageSize = -1;
	
	private int recordCount;
	
	private List<T> pagedData;
	
	private long totalCount;
	
	public PagedData(Page page,List<T> pagedData,long totalCount){
		if(page!=null){
			this.pageIndex = page.getPageIndex();
			this.pageSize = page.getPageSize();
		}
		this.totalCount = totalCount;
		this.recordCount = getRecordCount(pagedData);
		this.pagedData = pagedData;
	}
	
	public long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(long totalCount) {
		this.totalCount = totalCount;
	}

	private int getRecordCount(List<T> pagedData){
		if(pagedData==null) {
			return 0;
		}
		return pagedData.size();
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}

	public List<T> getPagedData() {
		return pagedData;
	}

	public void setPagedData(List<T> pagedData) {
		this.pagedData = pagedData;
	}
	
}
